<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Js extends Public_Controller {

	private $aFuncCalls = array();

	function __construct()
	{
		parent::__construct();
		$this->sSkinFile = 'ajax';
	}
	
	
	function index($sCalls = '', $sCache = 'Y')
	{
		if ($sCache !== 'N')
		{
			$this->output->set_header('Content-Type: text/javascript');
			$this->output->set_header("Expires: " . gmdate("D, d M Y H:i:s", (time() + 315360000)) . " GMT");
			$this->output->set_header("Cache-Control: max-age=315360000");
		}

		$sOutput = '';
		
		if ($sCalls !== '')
		{

			if (stristr($sCalls, $this->config->item('media_func_sep')) !== false)
			{
				$this->aFuncCalls = explode($this->config->item('media_func_sep'), $sCalls);
			}
			else 
			{
				$this->aFuncCalls[] = $sCalls;
			}
			
			foreach ($this->aFuncCalls as $sFuncCall)
			{
				if (substr($sFuncCall, 0 - strlen($this->config->item('js_ext'))) === $this->config->item('js_ext'))
				{
					$sFuncCall = substr($sFuncCall, 0, 0 - strlen($this->config->item('js_ext')));
				}
				
				if (method_exists($this, $sFuncCall) === true)
				{
					$sOutput .= $this->$sFuncCall().chr(10);
				}
			}
			
			
			if ($this->config->item('minify_js') === true)
			{
				
				$this->load->library('jsmin');
				
				$sOutput = $this->jsmin->minify($sOutput);
			}
		}
		
		$this->load->view('gen_output', array('output' => $sOutput));
	}
	
	
	
	/*JQUERY*/
	
	public function jquery()
	{
		return $this->load->view('media/jquery/jquery.php', $this->aData, true);
	}
	
	public function jquery_ui_core()
	{
		return $this->load->view('media/jquery/jquery-ui-core', $this->aData, true);
	}
	
	public function jquery_ui_draggable()
	{
		return $this->load->view('media/jquery/jquery-ui-draggable', $this->aData, true);
	}
	
	public function jquery_ui_sortable()
	{
		return $this->load->view('media/jquery/jquery-ui-sortable', $this->aData, true);
	}
	
	public function jquery_ui_sorted_nested_dependancies()
	{
		return $this->load->view('media/jquery/jquery-ui-sorted_nested_dependancies', $this->aData, true);
	}
	
	public function jquery_ui_sortable_nested()
	{
		return $this->load->view('media/jquery/jquery-ui-sortable_nested', $this->aData, true);
	}
	
	public function jquery_ui_datepicker()
	{
		return $this->load->view('media/jquery/jquery-ui-datepicker', $this->aData, true);
	}
	
	
	public function jquery_ui_slider()
	{
		return $this->load->view('media/jquery/jquery-ui-slider', $this->aData, true);
	}
	
	
	public function jquery_innerfade()
	{
		return $this->load->view('media/jquery/jquery.innerfade.php', $this->aData, true);
	}
	
	
	public function jquery_treeview()
	{
		return $this->load->view('media/jquery/jquery.treeview.php', $this->aData, true);
	}
	
	
	public function jquery_treeview_async()
	{
		return $this->load->view('media/jquery/jquery.treeview.async.php', $this->aData, true);
	}


	public function jquery_uploadify()
	{
		return $this->load->view('media/jquery/jquery.uploadify.php', $this->aData, true);	
	}


	public function jquery_uploadify_min()
	{
		return $this->load->view('media/jquery/jquery.uploadify.min.php', $this->aData, true);	
	}


	public function jquery_contextmenu()
	{
		return $this->load->view('media/jquery/jquery.context_menu.php', $this->aData, true);	
	}


	public function jquery_jcrop()
	{
		return $this->load->view('media/jquery/jquery.jcrop.php', $this->aData, true);	
	}


	public function jquery_hotkeys()
	{
		return $this->load->view('media/jquery/jquery.hotkeys.php', $this->aData, true);	
	}


	public function jquery_impromptu()
	{
		return $this->load->view('media/jquery/jquery.impromptu.php', $this->aData, true);	
	}
	

	public function jquery_jeditable()
	{
		return $this->load->view('media/jquery/jquery.jeditable.php', $this->aData, true);	
	}
	

	public function jquery_lightbox()
	{
		return $this->load->view('media/jquery/jquery.lightbox.php', $this->aData, true);	
	}

	
	
	/*TINYMCE*/
	
	public function tiny_mce()
	{
		return $this->load->view('media/js/tiny_mce', $this->aData, true);	
	}
	
	
	
	/*SWFOBJECT*/
	
	public function swfobject()
	{
		return $this->load->view('media/js/swfobject', $this->aData, true);	
	}
	
	
	
	/*FRONTEND*/
	
	public function generic()
	{
		return $this->load->view('media/js/generic', $this->aData, true);
	}
	
	
	
	/*ADMIN*/
	
	public function admin_login()
	{
		return $this->load->view('media/js/admin/login', $this->aData, true);
	}
	
	
	public function admin_x_domain_signin()
	{
		return $this->load->view('media/js/admin/x_domain_signin', $this->aData, true);	
	}
	
	
	public function admin_generic()
	{
		return $this->load->view('media/js/admin/generic', $this->aData, true);
	}
	
	
	public function admin_pages()
	{
		return $this->load->view('media/js/admin/pages', $this->aData, true);
	}
	
	public function admin_edit_page()
	{
		return $this->load->view('media/js/admin/edit_page', $this->aData, true);
	}

	public function admin_banners()
	{
		return $this->load->view('media/js/admin/banners', $this->aData, true);	
	}

	public function admin_banner_saved()
	{
		return $this->load->view('media/js/admin/banner_saved', $this->aData, true);	
	}
	
	public function admin_edit_banner()
	{
		return $this->load->view('media/js/admin/edit_banner', $this->aData, true);
	}

	public function admin_spotlights()
	{
		return $this->load->view('media/js/admin/spotlights', $this->aData, true);	
	}	
	
	public function admin_edit_spotlight()
	{
		return $this->load->view('media/js/admin/edit_spotlight', $this->aData, true);
	}
	
	public function admin_media()
	{
		return $this->load->view('media/js/admin/media', $this->aData, true);	
	}
	
	public function admin_media_popup()
	{
		return $this->load->view('media/js/admin/media_popup', $this->aData, true);	
	}	
	
	public function admin_edit_media()
	{
		
		$sRet = '';
		
		foreach ($this->config->item('admin_image_editing_tools') as $sJsInclude => $aVars) 
		{
			$sRet .= $this->load->view('media/js/admin/edit_media/'.$sJsInclude, $this->aData, true);
		}
		
		
		$sRet .= $this->load->view('media/js/admin/edit_media', $this->aData, true);
		

		
		return $sRet;
		
	}	
	
	
	public function admin_menu_order()
	{
		return $this->load->view('media/js/admin/menu_order', $this->aData, true);	
	}

	public function admin_edit_site()
	{
		return $this->load->view('media/js/admin/edit_site', $this->aData, true);	
	}	
	
	public function admin_edit_language() 
	{
		return $this->load->view('media/js/admin/edit_language', $this->aData, true);	
	}

	public function admin_gmaps()
	{
		return $this->load->view('media/js/admin/gmaps', $this->aData, true);	
	}	
	
	public function admin_edit_gmap()
	{
		return $this->load->view('media/js/admin/edit_gmap', $this->aData, true);
	}

	public function admin_short_urls()
	{
		return $this->load->view('media/js/admin/short_urls', $this->aData, true);	
	}

	public function admin_edit_short_url()
	{
		return $this->load->view('media/js/admin/edit_short_url', $this->aData, true);	
	}

	public function admin_access_rights()
	{
		return $this->load->view('media/js/admin/access_rights', $this->aData, true);	
	}
	
	
	public function admin_my_details()
	{
		return $this->load->view('media/js/admin/my_details', $this->aData, true);	
	}
	
	
	public function admin_edit_ext_media()
	{
		return $this->load->view('media/js/admin/edit_ext_media', $this->aData, true);	
	}
	
	public function admin_components()
	{
		return $this->load->view('media/js/admin/components', $this->aData, true);	
	}
	
	public function admin_projects()
	{
		return $this->load->view('media/js/admin/projects', $this->aData, true);
	}
	
	
	
	/*CODEMIRROR*/
	
	public function codemirror()
	{
		$sRet = $this->load->view('media/js/admin/codemirror/codemirror', $this->aData, true);
		$sRet .= $this->load->view('media/js/admin/codemirror/mode/xml/xml', $this->aData, true);
		$sRet .= $this->load->view('media/js/admin/codemirror/mode/css/css', $this->aData, true);
		$sRet .= $this->load->view('media/js/admin/codemirror/mode/javascript/javascript', $this->aData, true);
		$sRet .= $this->load->view('media/js/admin/codemirror/mode/htmlmixed/htmlmixed', $this->aData, true);
		
		return  $sRet;
	}
}

?>
